/*
 * Creation : 25/09/2013
 */
/**
 * 
 */
package com.japcatalog.batch;

import java.util.ArrayList;
import java.util.Collection;

import org.apache.log4j.Logger;

import com.japcatalog.dao.TrademarkDao;
import com.japcatalog.dao.impl.TrademarkDaoImpl;
import com.japcatalog.model.Provider;
import com.japcatalog.model.Trademark;

/**
 * 
 * @author Fernando Ariel Perelli
 * 
 */
public class SetUpDB {

	private static Logger logger = Logger.getLogger(SetUpDB.class);

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		logger.info("Create DataBase");
		Trademark trademark = new Trademark();
		Provider provider = new Provider();
		provider.setProviderName("Pepe");
		Collection<Provider> providers = new ArrayList<Provider>();
		providers.add(provider);
		trademark.setProviders(providers);
		trademark.setCompanyName("Pichis Power");
		TrademarkDao trademarkDao = new TrademarkDaoImpl();
		Long id = trademarkDao.create(trademark);
		Collection<Trademark> trademarks = trademarkDao.findAll();
		for (Trademark trademark2 : trademarks) {
			if (trademark2.equals(trademarkDao.findById(id))) {
				logger.info("Los objetos son iguales:" + trademark.toString() + "  ==  " + trademark2.toString());
			}
		}

		logger.info("Drop DataBase");
	}
}
